#include <chrono>
#include <mutex>
#include <condition_variable>
#include <iostream>

std::mutex m;
std::condition_variable cv;
bool done{false};

bool wait_loop() {
    using namespace std::chrono_literals;
    auto now = std::chrono::steady_clock::now();
    auto const timeout = now + 1s;
    std::unique_lock<std::mutex> lk(m);
    while (!done) {
        if (cv.wait_until(lk, timeout) == std::cv_status::timeout) {
            auto elapsed_time = std::chrono::steady_clock::now() - now;
            std::cout << "elapsed time: " << std::chrono::duration_cast<std::chrono::milliseconds>(elapsed_time) << "\n";
            break;
        }
    }
    return done;
}

int main() {
    wait_loop();
    return 0;
}